<?php
include "../site_specific/project.php";
include "../includes/constants.php";
include "../site_specific/external_constants.php";
include "../includes/phpmailer/class.phpmailer.php";
include "../includes/phpmailer/class.smtp.php";
include "../includes/utilities.php";
include "../includes/pages.php";
include "../includes/database.php";
include "../includes/users.php";
include "../includes/date.php";
include "../includes/text.php";
include "../includes/files.php";

# Establish database connection
establishDatabaseConnection();

$page_id=$_GET["id"];

$page_times=$_GET["times"];

$sql="select * from mrt_pages where p_id=\"".$page_id."\"";

$question_searching_item="<a href=\"www.uq.edu.au\">solution</a>";

$current_data=getRecord($sql);

$page_xmlcontent=$current_data[0]["p_content"];

$page_content=parseFlashLinks(parseFlashXML($page_xmlcontent));

#Change the original hyper link style to the one with css
$main_output = ChangeHyperLinkStyle($page_content);

$seaching_content = getRecord("SELECT gl_letter,gl_term,gl_descripto FROM " . $PROJECT_DB_TABLES["glossary"] . " order by gl_letter");

#Replace the font family						  
$main_output=ReplaceFontFamily($main_output);

#For the keyword to be replaced by glossary
$main_output=marked_keyword_replace($main_output,$seaching_content);

#Automatically change all the glossary 
$main_output=glossary_replace($main_output,$seaching_content);
						  
#remove the none link Indentifier
$main_output=RemoveHyperlink($main_output,"***","###");
						  
#replace the reference indetifier.
$main_output=Replace_reference($main_output);

$content_table_removed=removetable($main_output);

$exersice_array=explode($question_searching_item,$content_table_removed);
							  
$content_answer=$exersice_array[$page_times];

echo $content_answer;

if(count($exersice_array)>=3&&$page_times<2){
$page_times++;
echo "<a href=\"javascript:expandAnswer('".$page_id."',".$page_times.",'div_quesiton_answer_1','answer_expand_img_1');\"><img id=\"answer_expand_img_1\" border=\"0\" src=\"../assets/images/tree/folder_closed_1.png\"></a><div id=\"div_quesiton_answer_1\"></div>";
}
?>